package com.hrsaas.ext.spider.core.url;

import com.hrsaas.ext.spider.util.Assert;

/**
 * <p>
 * 功能：主要及端口赋值检查
 * <p>
 * 
 * @author wangxiaoliang@kanzhun.com
 *
 *         2018年8月1日
 */
public class HostAndPort {

	public final String host;
	public final int port;

	public HostAndPort(String host, int port) {
		Assert.notNull("host", host);
		Assert.notNull("port", port);
		this.host = host;
		if (port <= 0 || port >= 65535) {
			throw new IllegalArgumentException("port invalid : " + port);
		}
		this.port = port;
	}

	public String toString() {
		return host.toString() + ":" + port;
	}

	public String host() {
		return host.toString();
	}

	public int port() {
		return port;
	}
}
